"Grid Gallery"
Bootstrap 4.1.1 Snippet by SANTANU CHOWDHURY

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="wrapper">
<div>
<img src="https://placehold.co/200x200" alt="dummy image">
</div>
<div class="horizontal">
<img src="https://placehold.co/800x400" alt="dummy image">
</div>
<div>
<img src="https://placehold.co/300x200" alt="dummy image">
</div>
<div>
<img src="https://placehold.co/200x300" alt="dummy image">
</div>
<div>
<img src="https://placehold.co/300x250" alt="dummy image">
</div>
<div class="big">
<img src="https://placehold.co/1000x1000" alt="dummy image">
</div>
<div>
<img src="https://placehold.co/500x500" alt="dummy image">
</div>
<div>
<img src="https://placehold.co/500x250" alt="dummy image">
</div>
<div class="vertical">
<img src="https://placehold.co/400x800" alt="dummy image">
</div>
<div>
<img src="https://placehold.co/200x200" alt="dummy image">
</div>
<div class="horizontal">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.wrapper{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 5px;
grid-auto-flow: dense;
}
.wrapper img{
object-fit: cover;
width: 100%;
height: 100%;
}
.big{
grid-column: auto / span 2;
grid-row: auto / span 2;
}
.horizontal{
grid-column: auto / span 2;
}
.vertical{
grid-row: auto / span 2;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: